﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Threading;
using System.IO;
using System.IO.Ports;
using Microsoft.Office.Core;
using Excel = Microsoft.Office.Interop.Excel;

namespace SCA_Check_ExcelFile
{
    public partial class SCA_Check_ExcelFile
    {

        private void Load_BT_Click(object sender, EventArgs e)
        {
            OpenFileDialog open_dialog = new OpenFileDialog();
            string file_name;
            string fInfo;

            open_dialog.Filter = "All files (*.*)|*.*|Excel 97-2003 file (*.xls)|*.xls|Excel file (*.xlsx)|*.xlsx|Commmand Delimited (*.csv)|*.csv";

            if (open_dialog.ShowDialog() == DialogResult.OK)
            {
                file_name = open_dialog.FileName;
                fInfo = Path.GetExtension(open_dialog.FileName);
                File_Name = file_name;
                File_Path_Lbl.Text = File_Name;
            }
        }

        private void Check_BT_Click(object sender, EventArgs e)
        {
            if (File.Exists(File_Name) == false)
            {
                MessageBox.Show("File doesn't exist: " + File_Name, "Error");
                return;
            }

            Check_Excel_File(File_Name);
        }
    }
}